/*
 * @Author: LIFM0623 1944099171@qq.com
 * @Date: 2024-01-12 21:44:35
 * @LastEditors: LIFM0623 1944099171@qq.com
 * @LastEditTime: 2024-03-29 15:43:19
 * @FilePath: \Scene_Back\src\camera-rotate\camera-rotate.controller.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Patch,
  Post,
  Req,
} from '@nestjs/common';
import { CameraRotateService } from './camera-rotate.service';
import { createCameraRotateDto } from './dto/create-cameraRotate.dto';
import { updateCameraRotateDto } from './dto/update-cameraRotate.dto';
import { Request } from 'express';

@Controller('camera-rotate')
export class CameraRotateController {
  constructor(private readonly cameraRotateService: CameraRotateService) {}

  @Post('createCameraRotateItem')
  createCameraRotateItem(
    @Body() createCarmeraRotateDto: createCameraRotateDto,
    @Req() request: Request,
  ) {
    const user = request.user;
    createCarmeraRotateDto.creator = (user as any).email;
    return this.cameraRotateService.createCameraRotateItem(createCarmeraRotateDto)
  }

  @Get('getAllCameraRotateItem')
  getAllCameraRotateItem() {
    return this.cameraRotateService.findAll();
  }

  @Get('getCameraRotateItemByUser/:creator')
  getCameraRotateItemByUser(@Param('creator') creator:string){
    return this.cameraRotateService.findUser(creator)
  }

  @Get('getCameraRotateItemById/:id')
  getCameraRotateItemById(@Param('id') id: string) {
    return this.cameraRotateService.findOne(id);
  }

  @Patch('updateCameraRotateItemById/:id')
  updateCameraRotateItemById(
    @Body() updateCameraItem: updateCameraRotateDto,
    @Param('id') id: string,
  ) {
    return this.cameraRotateService.update(id, updateCameraItem);
  }

  @Delete('deleteCameraRotateItemById/:id')
  deleteCameraRotateItemById(@Param('id') id: string) {
    return this.cameraRotateService.remove(id);
  }
}
